﻿using System;
using System.Configuration;

namespace OBoobsWallpaper.Configuration
{
    public interface IRssCacheConfig
    {
        TimeSpan MaxRssItemAge { get; }
        int MaxElements { get; }
    }

    public interface IRssManagerSchedulerConfig
    {
        TimeSpan Interval { get; }
    }

    public interface IRssLoaderConfig
    {
        string Url { get; }
    }

    public class Config : IRssCacheConfig, IRssManagerSchedulerConfig, IRssLoaderConfig
    {
        public TimeSpan MaxRssItemAge
        {
            get { return new TimeSpan(5, 0, 0, 0); }
        }

        public int MaxElements
        {
            get { return 20; }
        }

        public TimeSpan Interval { get; private set; }

        public string Url { get; set; }

        public Config()
        {
            Url = ConfigurationManager.AppSettings["RssScribbler.Url"];
            Interval = TimeSpan.FromSeconds(Double.Parse(ConfigurationManager.AppSettings["RssScribbler.Interval_Sec"]));
        }
    }
}